package com.lzq.model.strategy;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author : modify
 * @version : v1.0
 * @description :
 * @createTime : 2022/11/26 17:44
 * @updateUser : modify
 * @updateTime : 2022/11/26 17:44
 * @updateRemark : 策略模式
 */
public interface StrategyInterface {
    /**
     * 活动内容
     */
    void show();
}

class StrategyA implements StrategyInterface {

    @Override
    public void show() {
        System.out.println("买一送一");
    }
}

class StrategyB implements StrategyInterface {

    @Override
    public void show() {
        System.out.println("满200元减50元");
    }
}

class StrategyC implements StrategyInterface {

    @Override
    public void show() {
        System.out.println("满1000元加一元换购任意200元以下商品");
    }
}

class SalesMan {
    private StrategyInterface strategyInterface;

    public SalesMan(StrategyInterface strategyInterface) {
        this.strategyInterface = strategyInterface;
    }

    public void salesManShow() {
        strategyInterface.show();
    }
}

class Test {
    public static void main(String[] args) {
        SalesMan salesMan = new SalesMan(new StrategyB());
        salesMan.salesManShow();
    }

    public void arrays() {
        Integer[] a = {3, 5, 6, 7, 96, 43};
        Arrays.sort(a, new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
    }
}